package com.example.ecas.persistence;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.ecas.pojo.WcRdis;
import com.example.ecas.pojo.WcRpat;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface WcRdisMapper extends BaseMapper<WcRdis> {

    default WcRdis getWcRdis(int disId) {
        return this.selectById(disId);
    }

    default int addWcRdis(WcRdis wcRdis) {
        if (wcRdis == null) {
            return 0;
        }
        QueryWrapper<WcRdis> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dis_id", wcRdis.getDisId());
        if (!this.exists(queryWrapper)) {
            return this.insert(wcRdis);
        }
        return 0;
    }
}
